import type { GoodsItemListModel, GoodsItemModel } from './goods'
import type { userGetuserInfoReturnModel } from './user'
import type { AddressItem } from './address'

import request from '@/utils/http'

interface MyOrderGetListSendModel {
  page: number
  size: number
  orderStatus?: string
}

export interface MyOrderItem {
  id: number
  orderId: string
  userId: number
  goodsId: number
  adminId: number
  none_sku: boolean
  orderStatus: string
  descText: null | string
  addressId: number
  createTime: number
  updateTime: number
  goods: GoodsItemModel
  user: userGetuserInfoReturnModel
  address: AddressItem
  list: GoodsItemListModel[]
  cart_num?: number // 订单选择的商品数量选填
}

interface MyOrderGetListReturnModel {
  total: number
  pageNum: number
  page: number
  size: number
  list: MyOrderItem[]
}
/**
 * 根据状态获取我的订单列表
 */
export function myOrderGetList(params: MyOrderGetListSendModel) {
  return request<MyOrderGetListReturnModel>({
    url: '/myOrder/getList',
    method: 'get',
    params,
  })
}

export enum OrderStatus {
  DFK = 'DFK',
  DFH = 'DFH',
  DSH = 'DSH',
  DPJ = 'DPJ',
  YQX = 'YQX',
  YWC = 'YWC',
}

export interface MyOrderSetDFHSendModel {
  id: number
  orderStatus: OrderStatus
}
/** 改变代发货商品状态（模拟发货） */
export function myOrderSetDFH(data: MyOrderSetDFHSendModel) {
  return request({
    url: '/myOrder/setDFH',
    method: 'post',
    data,
  })
}
